using MicroMsg.Storage;
using System;
namespace MicroMsg.Manager
{
	public class GConfigMgr
	{
		private static StorageKeyValue storageKeyValue_0 = new StorageKeyValue(new Func<string>(StorageIO.getGlobalConfigPath));
		public static SysSettings settings
		{
			get
			{
				return GConfigMgr.smethod_0<SysSettings>();
			}
		}
		public static void init()
		{
			StorageIO.initGlobalConfigRootDir();
			if (!GConfigMgr.storageKeyValue_0.exist<SysSettings>() && SettingsStorage.count() > 0)
			{
				SysSettings sysSettings = new SysSettings();
				SettingsStorage.load(sysSettings);
				GConfigMgr.storageKeyValue_0.write<SysSettings>(sysSettings);
			}
		}
		public static T smethod_0<T>() where T : class
		{
			return GConfigMgr.storageKeyValue_0.method_0<T>();
		}
		public static bool save<T>(bool saveAndRemoveCache = false) where T : class
		{
			return GConfigMgr.storageKeyValue_0.save<T>(saveAndRemoveCache);
		}
		public static T read<T>() where T : class
		{
			return GConfigMgr.storageKeyValue_0.read<T>();
		}
		public static bool write<T>(T data) where T : class
		{
			return GConfigMgr.storageKeyValue_0.write<T>(data);
		}
		public static void delete<T>() where T : class
		{
			GConfigMgr.storageKeyValue_0.delete<T>();
		}
		public static bool delValue(string key_name)
		{
			return GConfigMgr.storageKeyValue_0.delValue(key_name);
		}
		public static int getInt(string key_name, int default_value = 0)
		{
			return GConfigMgr.storageKeyValue_0.getValue<int>(key_name, default_value);
		}
		public static bool setInt(string key_name, int value)
		{
			return GConfigMgr.storageKeyValue_0.setValue<int>(key_name, value);
		}
		public static ulong getUlong(string key_name, ulong default_value = 0uL)
		{
			return GConfigMgr.storageKeyValue_0.getValue<ulong>(key_name, default_value);
		}
		public static bool setUlong(string key_name, ulong value)
		{
			return GConfigMgr.storageKeyValue_0.setValue<ulong>(key_name, value);
		}
		public static double getDouble(string key_name, double default_value = 0.0)
		{
			return GConfigMgr.storageKeyValue_0.getValue<double>(key_name, default_value);
		}
		public static bool setDouble(string key_name, double value)
		{
			return GConfigMgr.storageKeyValue_0.setValue<double>(key_name, value);
		}
		public static string getString(string key_name, string default_value = "")
		{
			return GConfigMgr.storageKeyValue_0.getValue<string>(key_name, default_value);
		}
		public static bool setString(string key_name, string value)
		{
			return GConfigMgr.storageKeyValue_0.setValue<string>(key_name, value);
		}
		public static bool getBool(string key_name, bool default_value = false)
		{
			return GConfigMgr.storageKeyValue_0.getValue<bool>(key_name, default_value);
		}
		public static bool setBool(string key_name, bool value)
		{
			return GConfigMgr.storageKeyValue_0.setValue<bool>(key_name, value);
		}
		public static void saveSetting()
		{
			GConfigMgr.save<SysSettings>(false);
		}
	}
}
